<template>
  <div class="app">
    <van-nav-bar
      class="header"
      :title="title"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
      fixed
      v-if="$route.meta.isTopShow"
    />
    <keep-alive :max="1">
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>

    <van-tabbar v-model="active" v-if="$route.meta.isShow">
      <van-tabbar-item icon="home-o" to="/home">主页</van-tabbar-item>
      <van-tabbar-item icon="notes-o" to="/itemize">分类</van-tabbar-item>
      <van-tabbar-item icon="search" to="/goods">商品</van-tabbar-item>
      <van-tabbar-item
        icon="cart-o"
        :badge="$store.getters['carts/getAllCount']"
        to="/carts"
        >购物车</van-tabbar-item
      >
      <van-tabbar-item icon="setting-o" to="/install">设置</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      title: this.$route.meta.title,
      active: 0,
      value: ''
    }
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1)
    }
  },
  created() {
  },
  watch: {
    '$route.meta.title'(newVal) {
      this.title = newVal
    }
  }
}
</script>
<style lang="scss" scoped>
.app {
  padding-top: 46px;
  padding-bottom: 50px;
  // background: #f4f4f4;

  .header {
    background: #ff5000;
  }
}
</style>